### Makefile
### $Id: Makefile,v 1.11 2006/06/26 04:51:29 jurandy Exp $

CP = cp
MV = mv
RM = rm

EGREP = egrep

LATEX = latex
BIBTEX = bibtex
DVIPS = dvips
PS2PDF = ps2pdf
PDFLATEX = pdflatex

BIBFLAGS = -min-crossrefs=32768
DVIFLAGS = -Z -Pamz -Pcmz -Ppdf -G0 -t letter
PDFFLAGS = 

RERUN = "Rerun to get (cross-references|the bars) right"
RERUNBIB = "No file.*\.bbl"

SRC = $(shell egrep -l '^[^%]*\\begin\{document\}' *.tex)

all: install clean

install: dvips

uninstall:
	$(RM) -f $(SRC:%.tex=%.dvi) $(SRC:%.tex=%.ps) $(SRC:%.tex=%.pdf)

%.dvi:	%.tex
	$(LATEX) $<
	$(EGREP) -c $(RERUNBIB) $*.log && $(BIBTEX) $(BIBFLAGS) $* ; true
	while ( $(LATEX) $< ; $(EGREP) -c $(RERUN) $*.log ) do true ; done
	$(EGREP) -i "(Reference|Citation).*undefined" $*.log ; true

%.ps:	%.dvi
	$(DVIPS) $(DVIFLAGS) $< -o $@

%.dpp:	%.ps
	$(PS2PDF)  $(PDFFLAGS) $<

%.pdf:	%.tex
	$(PDFLATEX) $<
	$(EGREP) -c $(RERUNBIB) $*.log && $(BIBTEX) $(BIBFLAGS) $* ; true
	while ( $(PDFLATEX) $< ; $(EGREP) -c $(RERUN) $*.log ) do true ; done
	$(EGREP) -i "(Reference|Citation).*undefined" $*.log ; true

%.pic:	%.dpp
	$(MV) $*.pdf $*-pics.pdf

%.p4f:	%.pic %.pdf
	$(RM) -f $*.dvi $*.ps $*-pics.pdf

dvi:	$(SRC:%.tex=%.dvi)
ps:	$(SRC:%.tex=%.ps)
dvips:	$(SRC:%.tex=%.dpp)
pdftex:	$(SRC:%.tex=%.pdf)
ps4pdf:	$(SRC:%.tex=%.p4f)

clean:
	$(RM) -f *-pics.* core *.core *.log *.aux *.toc *.lo[fpta] \
	*.blg *.brf *.ind *.ilg *.idx *.glo *.gls *.nav *.snm *.pfg *.out

### Makefile ends here.

